package com.ziyun.erp.modules.order.dao;

import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.plugins.pagination.Pagination;
import com.ziyun.erp.modules.order.entity.OrderInfoEntity;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.ziyun.erp.modules.order.vo.OrderBonusVo;
import com.ziyun.erp.modules.order.vo.OrderInfoVo;
import com.ziyun.erp.modules.order.vo.OrderServicerVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 订单基础信息表
 * 
 * @author guizhao
 * @email ...
 * @date 2018-08-03 10:40:47
 */
@Service("orderInfoDao")
public interface OrderInfoDao extends BaseMapper<OrderInfoEntity> {

    /**
     * 查询销售订单数据总数
     * @param map 查询参数
     * @return
     */
    int countOrder(@Param("map") Map<String, Object> map);

    /**
     *  查询订单列表
     * @param map 查询参数
     * @return
     */
    List<OrderInfoVo> queryPageOrderList(@Param("map") Map<String, Object> map);

    /**
     *  查询大纸订单列表
     * @param map 查询参数
     * @return
     */
    List<OrderInfoVo> queryPagePaperOrderList(@Param("map") Map<String, Object> map);

    /**
     * 查询订单详情
     * @param orderId 订单号
     * @return
     */
    OrderInfoVo selectOrderInfoVoById(@Param("orderId") Long orderId);

    /**
     *  订单数据更新
     * @param orderId 订单号
     * @param map 修改参数
     * @return
     */
    int updateByMap(@Param("orderId") String orderId, @Param("map") Map<String, Object> map);

    List<OrderInfoEntity> selectNotSynZiyunOrderList(Pagination page, String startTime);

    List<OrderInfoEntity> selectPayChangeZiyunOrderPage(Page<OrderInfoEntity> page);

    List<OrderInfoEntity> selectReceiveChangeZiyunOrderPage(Page<OrderInfoEntity> page);

    List<OrderInfoEntity> selectCancleChangeZiyunOrderPage(Page<OrderInfoEntity> page);

    List<OrderInfoEntity> selectNotPayZiyunOrderPage(@Param("day")Integer day, @Param("promotionType") String promotionType);

    List<OrderInfoVo> queryPageMallOrderList(@Param("map")Map<String,Object> params);

    List<OrderInfoEntity> getAllOrder(Pagination page, Integer userId);

    void updateFinishStatus(@Param("orderIds")List<String> orderIds);

    List<OrderInfoEntity> selectNotSendConfirmPage(Page<OrderInfoEntity> page);

    List<OrderInfoEntity> selectNotProductOrderList(@Param("sellerId")Integer sellerId,@Param("datetime") String datetime);

    List<OrderBonusVo> selectSellerOrderList();

    List<OrderInfoEntity> selecOrderPayConfirmPage(Page<OrderInfoEntity> page);

    OrderServicerVo selectOrderServicer(@Param("orderId") Long orderId);

    @Select("SELECT DISTINCT a.`user_id`,a.`supplier_id` FROM order_info a LEFT JOIN store_member b ON a.supplier_id = b.seller_id AND a.`user_id` = b.`member_id` WHERE b.`sid` IS NULL AND a.`supplier_id` > 20 AND a.`status` IN ('active','finish')")
    List<Map<String,Object>> memberSyncTwb();
}
